fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / xml / XMLTrackedChangesContext.cxx
blob2232a1f592ad1763283d4edc99f7bef916e2ecac
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "XMLTrackedChangesContext.hxx"
21 #include "xmlimprt.hxx"
22 #include "xmlconti.hxx"
23 #include "XMLConverter.hxx"
24 #include "formulacell.hxx"
25 #include "textuno.hxx"
26 #include "editutil.hxx"
27 #include "document.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 <svl/sharedstringpool.hxx>
35 #include <com/sun/star/text/XTextCursor.hpp>
36 #include <com/sun/star/text/ControlCharacter.hpp>
38 using namespace com::sun::star;
39 using namespace xmloff::token;
41 class ScXMLChangeInfoContext : public SvXMLImportContext
43 ScMyActionInfo aInfo;
44 OUStringBuffer sAuthorBuffer;
45 OUStringBuffer sDateTimeBuffer;
46 OUStringBuffer sCommentBuffer;
47 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
48 sal_uInt32 nParagraphCount;
50 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
52 public:
53 ScXMLChangeInfoContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
54 const ::com::sun::star::uno::Reference<
55 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
56 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
57 virtual ~ScXMLChangeInfoContext();
59 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
60 const OUString& rLocalName,
61 const ::com::sun::star::uno::Reference<
62 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
64 virtual void EndElement() SAL_OVERRIDE;
67 class ScXMLBigRangeContext : public SvXMLImportContext
69 ScBigRange& rBigRange;
71 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
73 public:
74 ScXMLBigRangeContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
75 const ::com::sun::star::uno::Reference<
76 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
77 ScBigRange& rBigRange);
78 virtual ~ScXMLBigRangeContext();
80 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
81 const OUString& rLocalName,
82 const ::com::sun::star::uno::Reference<
83 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
85 virtual void EndElement() SAL_OVERRIDE;
88 class ScXMLCellContentDeletionContext : public SvXMLImportContext
90 OUString sFormulaAddress;
91 OUString sFormula;
92 OUString sFormulaNmsp;
93 OUString sInputString;
94 ScBigRange aBigRange;
95 double fValue;
96 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
97 ScCellValue maCell;
98 sal_uInt32 nID;
99 sal_Int32 nMatrixCols;
100 sal_Int32 nMatrixRows;
101 formula::FormulaGrammar::Grammar eGrammar;
102 sal_uInt16 nType;
103 sal_uInt8 nMatrixFlag;
104 bool bBigRange;
105 bool bContainsCell;
107 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
109 public:
110 ScXMLCellContentDeletionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
111 const ::com::sun::star::uno::Reference<
112 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
113 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
114 virtual ~ScXMLCellContentDeletionContext();
116 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
117 const OUString& rLocalName,
118 const ::com::sun::star::uno::Reference<
119 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
121 virtual void EndElement() SAL_OVERRIDE;
124 class ScXMLDependenceContext : public SvXMLImportContext
126 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
128 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
130 public:
131 ScXMLDependenceContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
132 const ::com::sun::star::uno::Reference<
133 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
134 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
135 virtual ~ScXMLDependenceContext();
137 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
138 const OUString& rLocalName,
139 const ::com::sun::star::uno::Reference<
140 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
142 virtual void EndElement() SAL_OVERRIDE;
145 class ScXMLDependingsContext : public SvXMLImportContext
147 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
149 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
151 public:
152 ScXMLDependingsContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
153 const ::com::sun::star::uno::Reference<
154 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
155 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
156 virtual ~ScXMLDependingsContext();
158 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
159 const OUString& rLocalName,
160 const ::com::sun::star::uno::Reference<
161 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
163 virtual void EndElement() SAL_OVERRIDE;
166 class ScXMLChangeDeletionContext : public SvXMLImportContext
168 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
170 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
172 public:
173 ScXMLChangeDeletionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
174 const ::com::sun::star::uno::Reference<
175 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
176 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
177 virtual ~ScXMLChangeDeletionContext();
179 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
180 const OUString& rLocalName,
181 const ::com::sun::star::uno::Reference<
182 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
184 virtual void EndElement() SAL_OVERRIDE;
187 class ScXMLDeletionsContext : public SvXMLImportContext
189 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
191 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
193 public:
194 ScXMLDeletionsContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
195 const ::com::sun::star::uno::Reference<
196 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
197 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
198 virtual ~ScXMLDeletionsContext();
200 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
201 const OUString& rLocalName,
202 const ::com::sun::star::uno::Reference<
203 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
205 virtual void EndElement() SAL_OVERRIDE;
208 class ScXMLChangeCellContext;
210 class ScXMLChangeTextPContext : public SvXMLImportContext
212 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList> xAttrList;
213 OUString sLName;
214 OUStringBuffer sText;
215 ScXMLChangeCellContext* pChangeCellContext;
216 SvXMLImportContext* pTextPContext;
217 sal_uInt16 nPrefix;
219 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
221 public:
223 ScXMLChangeTextPContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
224 const OUString& rLName,
225 const ::com::sun::star::uno::Reference<
226 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
227 ScXMLChangeCellContext* pChangeCellContext);
229 virtual ~ScXMLChangeTextPContext();
231 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
232 const OUString& rLocalName,
233 const ::com::sun::star::uno::Reference<
234 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
236 virtual void Characters( const OUString& rChars ) SAL_OVERRIDE;
238 virtual void EndElement() SAL_OVERRIDE;
241 class ScXMLChangeCellContext : public SvXMLImportContext
243 ScCellValue& mrOldCell;
245 OUString sText;
246 OUString& rInputString;
247 ScEditEngineTextObj* pEditTextObj;
248 double& rDateTimeValue;
249 double fValue;
250 sal_uInt16& rType;
251 bool bEmpty;
252 bool bFirstParagraph;
253 bool bString;
254 bool bFormula;
256 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
258 public:
259 ScXMLChangeCellContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
260 const ::com::sun::star::uno::Reference<
261 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
262 ScCellValue& rOldCell, OUString& sAddress,
263 OUString& rFormula, OUString& rFormulaNmsp,
264 formula::FormulaGrammar::Grammar& rGrammar,
265 OUString& rInputString, double& fValue, sal_uInt16& nType,
266 sal_uInt8& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows);
267 virtual ~ScXMLChangeCellContext();
269 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
270 const OUString& rLocalName,
271 const ::com::sun::star::uno::Reference<
272 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
274 void CreateTextPContext(bool bIsNewParagraph);
275 bool IsEditCell() { return pEditTextObj != 0; }
276 void SetText(const OUString& sTempText) { sText = sTempText; }
278 virtual void EndElement() SAL_OVERRIDE;
281 class ScXMLPreviousContext : public SvXMLImportContext
283 OUString sFormulaAddress;
284 OUString sFormula;
285 OUString sFormulaNmsp;
286 OUString sInputString;
287 double fValue;
288 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
289 ScCellValue maOldCell;
290 sal_uInt32 nID;
291 sal_Int32 nMatrixCols;
292 sal_Int32 nMatrixRows;
293 formula::FormulaGrammar::Grammar eGrammar;
294 sal_uInt16 nType;
295 sal_uInt8 nMatrixFlag;
297 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
299 public:
300 ScXMLPreviousContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
301 const ::com::sun::star::uno::Reference<
302 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
303 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
304 virtual ~ScXMLPreviousContext();
306 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
307 const OUString& rLocalName,
308 const ::com::sun::star::uno::Reference<
309 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
311 virtual void EndElement() SAL_OVERRIDE;
314 class ScXMLContentChangeContext : public SvXMLImportContext
316 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
317 ScBigRange aBigRange;
319 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
321 public:
322 ScXMLContentChangeContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
323 const ::com::sun::star::uno::Reference<
324 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
325 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
326 virtual ~ScXMLContentChangeContext();
328 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
329 const OUString& rLocalName,
330 const ::com::sun::star::uno::Reference<
331 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
332 virtual void EndElement() SAL_OVERRIDE;
335 class ScXMLInsertionContext : public SvXMLImportContext
337 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
339 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
341 public:
342 ScXMLInsertionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
343 const ::com::sun::star::uno::Reference<
344 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
345 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
346 virtual ~ScXMLInsertionContext();
348 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
349 const OUString& rLocalName,
350 const ::com::sun::star::uno::Reference<
351 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
352 virtual void EndElement() SAL_OVERRIDE;
355 class ScXMLInsertionCutOffContext : public SvXMLImportContext
357 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
359 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
361 public:
362 ScXMLInsertionCutOffContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
363 const ::com::sun::star::uno::Reference<
364 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
365 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
366 virtual ~ScXMLInsertionCutOffContext();
368 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
369 const OUString& rLocalName,
370 const ::com::sun::star::uno::Reference<
371 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
372 virtual void EndElement() SAL_OVERRIDE;
375 class ScXMLMovementCutOffContext : public SvXMLImportContext
377 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
379 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
381 public:
382 ScXMLMovementCutOffContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
383 const ::com::sun::star::uno::Reference<
384 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
385 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
386 virtual ~ScXMLMovementCutOffContext();
388 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
389 const OUString& rLocalName,
390 const ::com::sun::star::uno::Reference<
391 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
392 virtual void EndElement() SAL_OVERRIDE;
395 class ScXMLCutOffsContext : public SvXMLImportContext
397 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
399 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
401 public:
402 ScXMLCutOffsContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
403 const ::com::sun::star::uno::Reference<
404 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
405 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
406 virtual ~ScXMLCutOffsContext();
408 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
409 const OUString& rLocalName,
410 const ::com::sun::star::uno::Reference<
411 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
412 virtual void EndElement() SAL_OVERRIDE;
415 class ScXMLDeletionContext : public SvXMLImportContext
417 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
419 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
421 public:
422 ScXMLDeletionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
423 const ::com::sun::star::uno::Reference<
424 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
425 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
426 virtual ~ScXMLDeletionContext();
428 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
429 const OUString& rLocalName,
430 const ::com::sun::star::uno::Reference<
431 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
432 virtual void EndElement() SAL_OVERRIDE;
435 class ScXMLMovementContext : public SvXMLImportContext
437 ScBigRange aSourceRange;
438 ScBigRange aTargetRange;
439 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
441 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
443 public:
444 ScXMLMovementContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
445 const ::com::sun::star::uno::Reference<
446 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
447 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
448 virtual ~ScXMLMovementContext();
450 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
451 const OUString& rLocalName,
452 const ::com::sun::star::uno::Reference<
453 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
454 virtual void EndElement() SAL_OVERRIDE;
457 class ScXMLRejectionContext : public SvXMLImportContext
459 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
461 ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
463 public:
464 ScXMLRejectionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
465 const ::com::sun::star::uno::Reference<
466 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
467 ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
468 virtual ~ScXMLRejectionContext();
470 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
471 const OUString& rLocalName,
472 const ::com::sun::star::uno::Reference<
473 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) SAL_OVERRIDE;
474 virtual void EndElement() SAL_OVERRIDE;
477 ScXMLTrackedChangesContext::ScXMLTrackedChangesContext( ScXMLImport& rImport,
478 sal_uInt16 nPrfx,
479 const OUString& rLName,
480 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
481 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
482 SvXMLImportContext( rImport, nPrfx, rLName ),
483 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
485 rImport.LockSolarMutex();
486 pChangeTrackingImportHelper->SetChangeTrack(true);
488 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
489 for( sal_Int16 i=0; i < nAttrCount; ++i )
491 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
492 OUString aLocalName;
493 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
494 sAttrName, &aLocalName ));
495 const OUString& sValue(xAttrList->getValueByIndex( i ));
496 if (nPrefix == XML_NAMESPACE_TABLE)
498 if (IsXMLToken(aLocalName, XML_PROTECTION_KEY))
500 if (!sValue.isEmpty())
502 uno::Sequence<sal_Int8> aPass;
503 ::sax::Converter::decodeBase64(aPass, sValue);
504 pChangeTrackingImportHelper->SetProtection(aPass);
511 ScXMLTrackedChangesContext::~ScXMLTrackedChangesContext()
513 GetScImport().UnlockSolarMutex();
516 SvXMLImportContext *ScXMLTrackedChangesContext::CreateChildContext( sal_uInt16 nPrefix,
517 const OUString& rLocalName,
518 const ::com::sun::star::uno::Reference<
519 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
521 SvXMLImportContext *pContext(0);
523 if (nPrefix == XML_NAMESPACE_TABLE)
525 if (IsXMLToken(rLocalName, XML_CELL_CONTENT_CHANGE))
527 pContext = new ScXMLContentChangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
529 else if (IsXMLToken(rLocalName, XML_INSERTION))
531 pContext = new ScXMLInsertionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
533 else if (IsXMLToken(rLocalName, XML_DELETION))
535 pContext = new ScXMLDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
537 else if (IsXMLToken(rLocalName, XML_MOVEMENT))
539 pContext = new ScXMLMovementContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
541 else if (IsXMLToken(rLocalName, XML_REJECTION))
543 pContext = new ScXMLRejectionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
547 if( !pContext )
548 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
550 return pContext;
553 void ScXMLTrackedChangesContext::EndElement()
557 ScXMLChangeInfoContext::ScXMLChangeInfoContext( ScXMLImport& rImport,
558 sal_uInt16 nPrfx,
559 const OUString& rLName,
560 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
561 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
562 SvXMLImportContext( rImport, nPrfx, rLName ),
563 aInfo(),
564 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
565 nParagraphCount(0)
567 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
568 for( sal_Int16 i=0; i < nAttrCount; ++i )
570 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
571 OUString aLocalName;
572 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
573 sAttrName, &aLocalName ));
574 const OUString& sValue(xAttrList->getValueByIndex( i ));
576 if (nPrefix == XML_NAMESPACE_OFFICE)
578 if (IsXMLToken(aLocalName, XML_CHG_AUTHOR))
580 sAuthorBuffer = sValue;
582 else if (IsXMLToken(aLocalName, XML_CHG_DATE_TIME))
584 sDateTimeBuffer = sValue;
590 ScXMLChangeInfoContext::~ScXMLChangeInfoContext()
594 SvXMLImportContext *ScXMLChangeInfoContext::CreateChildContext( sal_uInt16 nPrefix,
595 const OUString& rLocalName,
596 const ::com::sun::star::uno::Reference<
597 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
599 SvXMLImportContext *pContext(0);
601 if( XML_NAMESPACE_DC == nPrefix )
603 if( IsXMLToken( rLocalName, XML_CREATOR ) )
604 pContext = new ScXMLContentContext(GetScImport(), nPrefix,
605 rLocalName, xAttrList, sAuthorBuffer);
606 else if( IsXMLToken( rLocalName, XML_DATE ) )
607 pContext = new ScXMLContentContext(GetScImport(), nPrefix,
608 rLocalName, xAttrList, sDateTimeBuffer);
610 else if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLocalName, XML_P)) )
612 if(nParagraphCount)
613 sCommentBuffer.append('\n');
614 ++nParagraphCount;
615 pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLocalName, xAttrList, sCommentBuffer);
618 if( !pContext )
619 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
621 return pContext;
624 void ScXMLChangeInfoContext::EndElement()
626 aInfo.sUser = sAuthorBuffer.makeStringAndClear();
627 ::sax::Converter::parseDateTime(aInfo.aDateTime, 0,
628 sDateTimeBuffer.makeStringAndClear());
629 aInfo.sComment = sCommentBuffer.makeStringAndClear();
630 pChangeTrackingImportHelper->SetActionInfo(aInfo);
633 ScXMLBigRangeContext::ScXMLBigRangeContext( ScXMLImport& rImport,
634 sal_uInt16 nPrfx,
635 const OUString& rLName,
636 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
637 ScBigRange& rTempBigRange ) :
638 SvXMLImportContext( rImport, nPrfx, rLName ),
639 rBigRange(rTempBigRange)
641 bool bColumn(false);
642 bool bRow(false);
643 bool bTable(false);
644 sal_Int32 nColumn(0);
645 sal_Int32 nRow(0);
646 sal_Int32 nTable(0);
647 sal_Int32 nStartColumn(0);
648 sal_Int32 nEndColumn(0);
649 sal_Int32 nStartRow(0);
650 sal_Int32 nEndRow(0);
651 sal_Int32 nStartTable(0);
652 sal_Int32 nEndTable(0);
653 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
654 for( sal_Int16 i=0; i < nAttrCount; ++i )
656 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
657 OUString aLocalName;
658 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
659 sAttrName, &aLocalName ));
660 const OUString& sValue(xAttrList->getValueByIndex( i ));
662 if (nPrefix == XML_NAMESPACE_TABLE)
664 if (IsXMLToken(aLocalName, XML_COLUMN))
666 ::sax::Converter::convertNumber(nColumn, sValue);
667 bColumn = true;
669 else if (IsXMLToken(aLocalName, XML_ROW))
671 ::sax::Converter::convertNumber(nRow, sValue);
672 bRow = true;
674 else if (IsXMLToken(aLocalName, XML_TABLE))
676 ::sax::Converter::convertNumber(nTable, sValue);
677 bTable = true;
679 else if (IsXMLToken(aLocalName, XML_START_COLUMN))
680 ::sax::Converter::convertNumber(nStartColumn, sValue);
681 else if (IsXMLToken(aLocalName, XML_END_COLUMN))
682 ::sax::Converter::convertNumber(nEndColumn, sValue);
683 else if (IsXMLToken(aLocalName, XML_START_ROW))
684 ::sax::Converter::convertNumber(nStartRow, sValue);
685 else if (IsXMLToken(aLocalName, XML_END_ROW))
686 ::sax::Converter::convertNumber(nEndRow, sValue);
687 else if (IsXMLToken(aLocalName, XML_START_TABLE))
688 ::sax::Converter::convertNumber(nStartTable, sValue);
689 else if (IsXMLToken(aLocalName, XML_END_TABLE))
690 ::sax::Converter::convertNumber(nEndTable, sValue);
693 if (bColumn)
694 nStartColumn = nEndColumn = nColumn;
695 if (bRow)
696 nStartRow = nEndRow = nRow;
697 if (bTable)
698 nStartTable = nEndTable = nTable;
699 rBigRange.Set(nStartColumn, nStartRow, nStartTable,
700 nEndColumn, nEndRow, nEndTable);
703 ScXMLBigRangeContext::~ScXMLBigRangeContext()
707 SvXMLImportContext *ScXMLBigRangeContext::CreateChildContext( sal_uInt16 nPrefix,
708 const OUString& rLocalName,
709 const ::com::sun::star::uno::Reference<
710 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
712 return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
715 void ScXMLBigRangeContext::EndElement()
719 ScXMLCellContentDeletionContext::ScXMLCellContentDeletionContext( ScXMLImport& rImport,
720 sal_uInt16 nPrfx,
721 const OUString& rLName,
722 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
723 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper) :
724 SvXMLImportContext( rImport, nPrfx, rLName ),
725 fValue(0.0),
726 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
727 nID(0),
728 nMatrixCols(0),
729 nMatrixRows(0),
730 eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT),
731 nType(css::util::NumberFormat::ALL),
732 nMatrixFlag(MM_NONE),
733 bBigRange(false),
734 bContainsCell(false)
736 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
737 for( sal_Int16 i=0; i < nAttrCount; ++i )
739 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
740 OUString aLocalName;
741 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
742 sAttrName, &aLocalName ));
743 const OUString& sValue(xAttrList->getValueByIndex( i ));
745 if (nPrefix == XML_NAMESPACE_TABLE)
747 if (IsXMLToken(aLocalName, XML_ID))
748 nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
753 ScXMLCellContentDeletionContext::~ScXMLCellContentDeletionContext()
757 SvXMLImportContext *ScXMLCellContentDeletionContext::CreateChildContext( sal_uInt16 nPrefix,
758 const OUString& rLocalName,
759 const ::com::sun::star::uno::Reference<
760 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
762 SvXMLImportContext *pContext(0);
764 if (nPrefix == XML_NAMESPACE_TABLE)
766 if (IsXMLToken(rLocalName, XML_CHANGE_TRACK_TABLE_CELL))
768 bContainsCell = true;
769 pContext = new ScXMLChangeCellContext(GetScImport(), nPrefix, rLocalName, xAttrList,
770 maCell, sFormulaAddress, sFormula, sFormulaNmsp, eGrammar, sInputString, fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows );
772 else if (IsXMLToken(rLocalName, XML_CELL_ADDRESS))
774 OSL_ENSURE(!nID, "a action with a ID should not contain a BigRange");
775 bBigRange = true;
776 pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aBigRange);
780 if( !pContext )
781 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
783 return pContext;
786 void ScXMLCellContentDeletionContext::EndElement()
788 ScMyCellInfo* pCellInfo(new ScMyCellInfo(maCell, sFormulaAddress, sFormula, eGrammar, sInputString, fValue, nType,
789 nMatrixFlag, nMatrixCols, nMatrixRows));
790 if (nID)
791 pChangeTrackingImportHelper->AddDeleted(nID, pCellInfo);
792 else
793 pChangeTrackingImportHelper->AddGenerated(pCellInfo, aBigRange);
796 ScXMLDependenceContext::ScXMLDependenceContext( ScXMLImport& rImport,
797 sal_uInt16 nPrfx,
798 const OUString& rLName,
799 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
800 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
801 SvXMLImportContext( rImport, nPrfx, rLName ),
802 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
804 sal_uInt32 nID(0);
805 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
806 for( sal_Int16 i=0; i < nAttrCount; ++i )
808 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
809 OUString aLocalName;
810 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
811 sAttrName, &aLocalName ));
812 const OUString& sValue(xAttrList->getValueByIndex( i ));
814 if (nPrefix == XML_NAMESPACE_TABLE)
816 if (IsXMLToken(aLocalName, XML_ID))
817 nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
820 pChangeTrackingImportHelper->AddDependence(nID);
823 ScXMLDependenceContext::~ScXMLDependenceContext()
827 SvXMLImportContext *ScXMLDependenceContext::CreateChildContext( sal_uInt16 nPrefix,
828 const OUString& rLocalName,
829 const ::com::sun::star::uno::Reference<
830 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
832 return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
835 void ScXMLDependenceContext::EndElement()
839 ScXMLDependingsContext::ScXMLDependingsContext( ScXMLImport& rImport,
840 sal_uInt16 nPrfx,
841 const OUString& rLName,
842 const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */,
843 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
844 SvXMLImportContext( rImport, nPrfx, rLName ),
845 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
847 // here are no attributes
850 ScXMLDependingsContext::~ScXMLDependingsContext()
854 SvXMLImportContext *ScXMLDependingsContext::CreateChildContext( sal_uInt16 nPrefix,
855 const OUString& rLocalName,
856 const ::com::sun::star::uno::Reference<
857 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
859 SvXMLImportContext *pContext(0);
861 if (nPrefix == XML_NAMESPACE_TABLE)
863 // #i80033# read both old (dependence) and new (dependency) elements
864 if (IsXMLToken(rLocalName, XML_DEPENDENCE) || IsXMLToken(rLocalName, XML_DEPENDENCY))
865 pContext = new ScXMLDependenceContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
868 if( !pContext )
869 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
871 return pContext;
874 void ScXMLDependingsContext::EndElement()
878 ScXMLChangeDeletionContext::ScXMLChangeDeletionContext( ScXMLImport& rImport,
879 sal_uInt16 nPrfx,
880 const OUString& rLName,
881 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
882 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
883 SvXMLImportContext( rImport, nPrfx, rLName ),
884 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
886 sal_uInt32 nID(0);
887 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
888 for( sal_Int16 i=0; i < nAttrCount; ++i )
890 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
891 OUString aLocalName;
892 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
893 sAttrName, &aLocalName ));
894 const OUString& sValue(xAttrList->getValueByIndex( i ));
896 if (nPrefix == XML_NAMESPACE_TABLE)
898 if (IsXMLToken(aLocalName, XML_ID))
899 nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
902 pChangeTrackingImportHelper->AddDeleted(nID);
905 ScXMLChangeDeletionContext::~ScXMLChangeDeletionContext()
909 SvXMLImportContext *ScXMLChangeDeletionContext::CreateChildContext( sal_uInt16 nPrefix,
910 const OUString& rLocalName,
911 const ::com::sun::star::uno::Reference<
912 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
914 return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
917 void ScXMLChangeDeletionContext::EndElement()
921 ScXMLDeletionsContext::ScXMLDeletionsContext( ScXMLImport& rImport,
922 sal_uInt16 nPrfx,
923 const OUString& rLName,
924 const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */,
925 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
926 SvXMLImportContext( rImport, nPrfx, rLName ),
927 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
929 // here are no attributes
932 ScXMLDeletionsContext::~ScXMLDeletionsContext()
936 SvXMLImportContext *ScXMLDeletionsContext::CreateChildContext( sal_uInt16 nPrefix,
937 const OUString& rLocalName,
938 const ::com::sun::star::uno::Reference<
939 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
941 SvXMLImportContext *pContext(0);
943 if (nPrefix == XML_NAMESPACE_TABLE)
945 if (IsXMLToken(rLocalName, XML_CHANGE_DELETION))
946 pContext = new ScXMLChangeDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
947 else if (IsXMLToken(rLocalName, XML_CELL_CONTENT_DELETION))
948 pContext = new ScXMLCellContentDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
951 if( !pContext )
952 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
954 return pContext;
957 void ScXMLDeletionsContext::EndElement()
961 ScXMLChangeTextPContext::ScXMLChangeTextPContext( ScXMLImport& rImport,
962 sal_uInt16 nPrfx,
963 const OUString& rLName,
964 const ::com::sun::star::uno::Reference<
965 ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList,
966 ScXMLChangeCellContext* pTempChangeCellContext) :
967 SvXMLImportContext( rImport, nPrfx, rLName ),
968 xAttrList(xTempAttrList),
969 sLName(rLName),
970 sText(),
971 pChangeCellContext(pTempChangeCellContext),
972 pTextPContext(NULL),
973 nPrefix(nPrfx)
975 // here are no attributes
978 ScXMLChangeTextPContext::~ScXMLChangeTextPContext()
980 if (pTextPContext)
981 delete pTextPContext;
984 SvXMLImportContext *ScXMLChangeTextPContext::CreateChildContext( sal_uInt16 nTempPrefix,
985 const OUString& rLName,
986 const ::com::sun::star::uno::Reference<
987 ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList )
989 SvXMLImportContext *pContext(0);
991 if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLName, XML_S)) && !pTextPContext)
993 sal_Int32 nRepeat(0);
994 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
995 for( sal_Int16 i=0; i < nAttrCount; ++i )
997 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
998 const OUString& sValue(xAttrList->getValueByIndex( i ));
999 OUString aLocalName;
1000 sal_uInt16 nPrfx(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1001 sAttrName, &aLocalName ));
1002 if ((nPrfx == XML_NAMESPACE_TEXT) && (IsXMLToken(aLocalName, XML_C)))
1003 nRepeat = sValue.toInt32();
1005 if (nRepeat)
1006 for (sal_Int32 j = 0; j < nRepeat; ++j)
1007 sText.append(' ');
1008 else
1009 sText.append(' ');
1011 else
1013 if (!pChangeCellContext->IsEditCell())
1014 pChangeCellContext->CreateTextPContext(false);
1015 bool bWasContext (true);
1016 if (!pTextPContext)
1018 bWasContext = false;
1019 pTextPContext = GetScImport().GetTextImport()->CreateTextChildContext(
1020 GetScImport(), nPrefix, sLName, xAttrList);
1022 if (pTextPContext)
1024 if (!bWasContext)
1025 pTextPContext->Characters(sText.makeStringAndClear());
1026 pContext = pTextPContext->CreateChildContext(nTempPrefix, rLName, xTempAttrList);
1030 if( !pContext )
1031 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1033 return pContext;
1036 void ScXMLChangeTextPContext::Characters( const OUString& rChars )
1038 if (!pTextPContext)
1039 sText.append(rChars);
1040 else
1041 pTextPContext->Characters(rChars);
1044 void ScXMLChangeTextPContext::EndElement()
1046 if (!pTextPContext)
1047 pChangeCellContext->SetText(sText.makeStringAndClear());
1050 ScXMLChangeCellContext::ScXMLChangeCellContext( ScXMLImport& rImport,
1051 sal_uInt16 nPrfx,
1052 const OUString& rLName,
1053 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1054 ScCellValue& rOldCell, OUString& rAddress,
1055 OUString& rFormula, OUString& rFormulaNmsp,
1056 formula::FormulaGrammar::Grammar& rGrammar,
1057 OUString& rTempInputString, double& fDateTimeValue, sal_uInt16& nType,
1058 sal_uInt8& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows )
1059 : SvXMLImportContext( rImport, nPrfx, rLName )
1060 , mrOldCell(rOldCell)
1061 , rInputString(rTempInputString)
1062 , pEditTextObj(NULL)
1063 , rDateTimeValue(fDateTimeValue)
1064 , fValue(0.0)
1065 , rType(nType)
1066 , bEmpty(true)
1067 , bFirstParagraph(true)
1068 , bString(true)
1069 , bFormula(false)
1071 bool bIsMatrix(false);
1072 bool bIsCoveredMatrix(false);
1073 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1074 for( sal_Int16 i=0; i < nAttrCount; ++i )
1076 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1077 OUString aLocalName;
1078 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1079 sAttrName, &aLocalName ));
1080 const OUString& sValue(xAttrList->getValueByIndex( i ));
1082 if (nPrefix == XML_NAMESPACE_TABLE)
1084 if (IsXMLToken(aLocalName, XML_FORMULA))
1086 bEmpty = false;
1087 GetScImport().ExtractFormulaNamespaceGrammar( rFormula, rFormulaNmsp, rGrammar, sValue );
1088 bFormula = true;
1090 else if (IsXMLToken(aLocalName, XML_CELL_ADDRESS))
1092 rAddress = sValue;
1094 else if (IsXMLToken(aLocalName, XML_MATRIX_COVERED))
1096 bIsCoveredMatrix = IsXMLToken(sValue, XML_TRUE);
1098 else if (IsXMLToken(aLocalName, XML_NUMBER_MATRIX_COLUMNS_SPANNED))
1100 bIsMatrix = true;
1101 ::sax::Converter::convertNumber(nMatrixCols, sValue);
1103 else if (IsXMLToken(aLocalName, XML_NUMBER_MATRIX_ROWS_SPANNED))
1105 bIsMatrix = true;
1106 ::sax::Converter::convertNumber(nMatrixRows, sValue);
1109 else if (nPrefix == XML_NAMESPACE_OFFICE)
1111 if (IsXMLToken(aLocalName, XML_VALUE_TYPE))
1113 if (IsXMLToken(sValue, XML_FLOAT))
1114 bString = false;
1115 else if (IsXMLToken(sValue, XML_DATE))
1117 rType = css::util::NumberFormat::DATE;
1118 bString = false;
1120 else if (IsXMLToken(sValue, XML_TIME))
1122 rType = css::util::NumberFormat::TIME;
1123 bString = false;
1126 else if (IsXMLToken(aLocalName, XML_VALUE))
1128 ::sax::Converter::convertDouble(fValue, sValue);
1129 bEmpty = false;
1131 else if (IsXMLToken(aLocalName, XML_DATE_VALUE))
1133 bEmpty = false;
1134 if (GetScImport().GetMM100UnitConverter().setNullDate(GetScImport().GetModel()))
1135 GetScImport().GetMM100UnitConverter().convertDateTime(rDateTimeValue, sValue);
1136 fValue = rDateTimeValue;
1138 else if (IsXMLToken(aLocalName, XML_TIME_VALUE))
1140 bEmpty = false;
1141 ::sax::Converter::convertDuration(rDateTimeValue, sValue);
1142 fValue = rDateTimeValue;
1146 if (bIsCoveredMatrix)
1147 nMatrixFlag = MM_REFERENCE;
1148 else if (bIsMatrix && nMatrixRows && nMatrixCols)
1149 nMatrixFlag = MM_FORMULA;
1152 ScXMLChangeCellContext::~ScXMLChangeCellContext()
1156 SvXMLImportContext *ScXMLChangeCellContext::CreateChildContext( sal_uInt16 nPrefix,
1157 const OUString& rLocalName,
1158 const ::com::sun::star::uno::Reference<
1159 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1161 SvXMLImportContext *pContext(0);
1163 if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLocalName, XML_P)))
1165 bEmpty = false;
1166 if (bFirstParagraph)
1168 pContext = new ScXMLChangeTextPContext(GetScImport(), nPrefix, rLocalName, xAttrList, this);
1169 bFirstParagraph = false;
1171 else
1173 if (!pEditTextObj)
1174 CreateTextPContext(true);
1175 pContext = GetScImport().GetTextImport()->CreateTextChildContext(
1176 GetScImport(), nPrefix, rLocalName, xAttrList);
1180 if( !pContext )
1181 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1183 return pContext;
1186 void ScXMLChangeCellContext::CreateTextPContext(bool bIsNewParagraph)
1188 if (GetScImport().GetDocument())
1190 pEditTextObj = new ScEditEngineTextObj();
1191 pEditTextObj->acquire();
1192 pEditTextObj->GetEditEngine()->SetEditTextObjectPool(GetScImport().GetDocument()->GetEditPool());
1193 uno::Reference <text::XText> xText(pEditTextObj);
1194 if (xText.is())
1196 uno::Reference<text::XTextCursor> xTextCursor(xText->createTextCursor());
1197 if (bIsNewParagraph)
1199 xText->setString(sText);
1200 xTextCursor->gotoEnd(false);
1201 uno::Reference < text::XTextRange > xTextRange (xTextCursor, uno::UNO_QUERY);
1202 if (xTextRange.is())
1203 xText->insertControlCharacter(xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, false);
1205 GetScImport().GetTextImport()->SetCursor(xTextCursor);
1210 void ScXMLChangeCellContext::EndElement()
1212 if (!bEmpty)
1214 ScDocument* pDoc = GetScImport().GetDocument();
1215 if (pEditTextObj)
1217 if (GetImport().GetTextImport()->GetCursor().is())
1219 //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False);
1220 if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) )
1222 OUString sEmpty;
1223 GetImport().GetTextImport()->GetText()->insertString(
1224 GetImport().GetTextImport()->GetCursorAsRange(), sEmpty,
1225 sal_True );
1229 // The cell will own the text object instance.
1230 mrOldCell.meType = CELLTYPE_EDIT;
1231 mrOldCell.mpEditText = pEditTextObj->CreateTextObject();
1232 GetScImport().GetTextImport()->ResetCursor();
1233 pEditTextObj->release();
1235 else
1237 if (!bFormula)
1239 if (!sText.isEmpty() && bString)
1241 mrOldCell.meType = CELLTYPE_STRING;
1242 mrOldCell.mpString = new svl::SharedString(pDoc->GetSharedStringPool().intern(sText));
1244 else
1246 mrOldCell.meType = CELLTYPE_VALUE;
1247 mrOldCell.mfValue = fValue;
1249 if (rType == css::util::NumberFormat::DATE || rType == css::util::NumberFormat::TIME)
1250 rInputString = sText;
1254 else
1255 mrOldCell.clear();
1258 ScXMLPreviousContext::ScXMLPreviousContext( ScXMLImport& rImport,
1259 sal_uInt16 nPrfx,
1260 const OUString& rLName,
1261 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1262 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1263 SvXMLImportContext( rImport, nPrfx, rLName ),
1264 fValue(0.0),
1265 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
1266 nID(0),
1267 nMatrixCols(0),
1268 nMatrixRows(0),
1269 eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT),
1270 nType(css::util::NumberFormat::ALL),
1271 nMatrixFlag(MM_NONE)
1273 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1274 for( sal_Int16 i=0; i < nAttrCount; ++i )
1276 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1277 OUString aLocalName;
1278 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1279 sAttrName, &aLocalName ));
1280 const OUString& sValue(xAttrList->getValueByIndex( i ));
1282 if (nPrefix == XML_NAMESPACE_TABLE)
1284 if (IsXMLToken(aLocalName, XML_ID))
1285 nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
1290 ScXMLPreviousContext::~ScXMLPreviousContext()
1294 SvXMLImportContext *ScXMLPreviousContext::CreateChildContext( sal_uInt16 nPrefix,
1295 const OUString& rLocalName,
1296 const ::com::sun::star::uno::Reference<
1297 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1299 SvXMLImportContext *pContext(0);
1301 if ((nPrefix == XML_NAMESPACE_TABLE) && (IsXMLToken(rLocalName, XML_CHANGE_TRACK_TABLE_CELL)))
1302 pContext = new ScXMLChangeCellContext(GetScImport(), nPrefix, rLocalName, xAttrList,
1303 maOldCell, sFormulaAddress, sFormula, sFormulaNmsp, eGrammar, sInputString, fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows);
1305 if( !pContext )
1306 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1308 return pContext;
1311 void ScXMLPreviousContext::EndElement()
1313 pChangeTrackingImportHelper->SetPreviousChange(nID, new ScMyCellInfo(maOldCell, sFormulaAddress, sFormula, eGrammar, sInputString,
1314 fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows));
1317 ScXMLContentChangeContext::ScXMLContentChangeContext( ScXMLImport& rImport,
1318 sal_uInt16 nPrfx,
1319 const OUString& rLName,
1320 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1321 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1322 SvXMLImportContext( rImport, nPrfx, rLName ),
1323 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1325 sal_uInt32 nActionNumber(0);
1326 sal_uInt32 nRejectingNumber(0);
1327 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1329 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1330 for( sal_Int16 i=0; i < nAttrCount; ++i )
1332 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1333 OUString aLocalName;
1334 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1335 sAttrName, &aLocalName ));
1336 const OUString& sValue(xAttrList->getValueByIndex( i ));
1338 if (nPrefix == XML_NAMESPACE_TABLE)
1340 if (IsXMLToken(aLocalName, XML_ID))
1342 nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1344 else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1346 if (IsXMLToken(sValue, XML_ACCEPTED))
1347 nActionState = SC_CAS_ACCEPTED;
1348 else if (IsXMLToken(sValue, XML_REJECTED))
1349 nActionState = SC_CAS_REJECTED;
1351 else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1353 nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1358 pChangeTrackingImportHelper->StartChangeAction(SC_CAT_CONTENT);
1359 pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1360 pChangeTrackingImportHelper->SetActionState(nActionState);
1361 pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1364 ScXMLContentChangeContext::~ScXMLContentChangeContext()
1368 SvXMLImportContext *ScXMLContentChangeContext::CreateChildContext( sal_uInt16 nPrefix,
1369 const OUString& rLocalName,
1370 const ::com::sun::star::uno::Reference<
1371 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1373 SvXMLImportContext *pContext(0);
1375 if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1377 pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1379 else if (nPrefix == XML_NAMESPACE_TABLE)
1381 if (IsXMLToken(rLocalName, XML_CELL_ADDRESS))
1383 pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aBigRange);
1385 else if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1387 pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1389 else if (IsXMLToken(rLocalName, XML_DELETIONS))
1390 pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1391 else if (IsXMLToken(rLocalName, XML_PREVIOUS))
1393 pContext = new ScXMLPreviousContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1397 if( !pContext )
1398 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1400 return pContext;
1403 void ScXMLContentChangeContext::EndElement()
1405 pChangeTrackingImportHelper->SetBigRange(aBigRange);
1406 pChangeTrackingImportHelper->EndChangeAction();
1409 ScXMLInsertionContext::ScXMLInsertionContext( ScXMLImport& rImport,
1410 sal_uInt16 nPrfx,
1411 const OUString& rLName,
1412 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1413 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1414 SvXMLImportContext( rImport, nPrfx, rLName ),
1415 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1417 sal_uInt32 nActionNumber(0);
1418 sal_uInt32 nRejectingNumber(0);
1419 sal_Int32 nPosition(0);
1420 sal_Int32 nCount(1);
1421 sal_Int32 nTable(0);
1422 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1423 ScChangeActionType nActionType(SC_CAT_INSERT_COLS);
1425 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1426 for( sal_Int16 i=0; i < nAttrCount; ++i )
1428 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1429 OUString aLocalName;
1430 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1431 sAttrName, &aLocalName ));
1432 const OUString& sValue(xAttrList->getValueByIndex( i ));
1434 if (nPrefix == XML_NAMESPACE_TABLE)
1436 if (IsXMLToken(aLocalName, XML_ID))
1438 nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1440 else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1442 if (IsXMLToken(sValue, XML_ACCEPTED))
1443 nActionState = SC_CAS_ACCEPTED;
1444 else if (IsXMLToken(sValue, XML_REJECTED))
1445 nActionState = SC_CAS_REJECTED;
1447 else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1449 nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1451 else if (IsXMLToken(aLocalName, XML_TYPE))
1453 if (IsXMLToken(sValue, XML_ROW))
1454 nActionType = SC_CAT_INSERT_ROWS;
1455 else if (IsXMLToken(sValue, XML_TABLE))
1456 nActionType = SC_CAT_INSERT_TABS;
1458 else if (IsXMLToken(aLocalName, XML_POSITION))
1460 ::sax::Converter::convertNumber(nPosition, sValue);
1462 else if (IsXMLToken(aLocalName, XML_TABLE))
1464 ::sax::Converter::convertNumber(nTable, sValue);
1466 else if (IsXMLToken(aLocalName, XML_COUNT))
1468 ::sax::Converter::convertNumber(nCount, sValue);
1473 pChangeTrackingImportHelper->StartChangeAction(nActionType);
1474 pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1475 pChangeTrackingImportHelper->SetActionState(nActionState);
1476 pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1477 pChangeTrackingImportHelper->SetPosition(nPosition, nCount, nTable);
1480 ScXMLInsertionContext::~ScXMLInsertionContext()
1484 SvXMLImportContext *ScXMLInsertionContext::CreateChildContext( sal_uInt16 nPrefix,
1485 const OUString& rLocalName,
1486 const ::com::sun::star::uno::Reference<
1487 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1489 SvXMLImportContext *pContext(0);
1491 if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1493 pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1495 else if (nPrefix == XML_NAMESPACE_TABLE)
1497 if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1498 pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1499 else if (IsXMLToken(rLocalName, XML_DELETIONS))
1500 pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1503 if( !pContext )
1504 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1506 return pContext;
1509 void ScXMLInsertionContext::EndElement()
1511 pChangeTrackingImportHelper->EndChangeAction();
1514 ScXMLInsertionCutOffContext::ScXMLInsertionCutOffContext( ScXMLImport& rImport,
1515 sal_uInt16 nPrfx,
1516 const OUString& rLName,
1517 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1518 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1519 SvXMLImportContext( rImport, nPrfx, rLName ),
1520 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1522 sal_uInt32 nID(0);
1523 sal_Int32 nPosition(0);
1524 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1525 for( sal_Int16 i=0; i < nAttrCount; ++i )
1527 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1528 OUString aLocalName;
1529 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1530 sAttrName, &aLocalName ));
1531 const OUString& sValue(xAttrList->getValueByIndex( i ));
1533 if (nPrefix == XML_NAMESPACE_TABLE)
1535 if (IsXMLToken(aLocalName, XML_ID))
1537 nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
1539 else if (IsXMLToken(aLocalName, XML_POSITION))
1541 ::sax::Converter::convertNumber(nPosition, sValue);
1545 pChangeTrackingImportHelper->SetInsertionCutOff(nID, nPosition);
1548 ScXMLInsertionCutOffContext::~ScXMLInsertionCutOffContext()
1552 SvXMLImportContext *ScXMLInsertionCutOffContext::CreateChildContext( sal_uInt16 nPrefix,
1553 const OUString& rLocalName,
1554 const ::com::sun::star::uno::Reference<
1555 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1557 return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1560 void ScXMLInsertionCutOffContext::EndElement()
1564 ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport& rImport,
1565 sal_uInt16 nPrfx,
1566 const OUString& rLName,
1567 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1568 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1569 SvXMLImportContext( rImport, nPrfx, rLName ),
1570 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1572 sal_uInt32 nID(0);
1573 sal_Int32 nPosition(0);
1574 sal_Int32 nStartPosition(0);
1575 sal_Int32 nEndPosition(0);
1576 bool bPosition(false);
1577 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1578 for( sal_Int16 i=0; i < nAttrCount; ++i )
1580 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1581 OUString aLocalName;
1582 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1583 sAttrName, &aLocalName ));
1584 const OUString& sValue(xAttrList->getValueByIndex( i ));
1586 if (nPrefix == XML_NAMESPACE_TABLE)
1588 if (IsXMLToken(aLocalName, XML_ID))
1590 nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
1592 else if (IsXMLToken(aLocalName, XML_POSITION))
1594 bPosition = true;
1595 ::sax::Converter::convertNumber(nPosition, sValue);
1597 else if (IsXMLToken(aLocalName, XML_START_POSITION))
1599 ::sax::Converter::convertNumber(nStartPosition, sValue);
1601 else if (IsXMLToken(aLocalName, XML_END_POSITION))
1603 ::sax::Converter::convertNumber(nEndPosition, sValue);
1607 if (bPosition)
1608 nStartPosition = nEndPosition = nPosition;
1609 pChangeTrackingImportHelper->AddMoveCutOff(nID, nStartPosition, nEndPosition);
1612 ScXMLMovementCutOffContext::~ScXMLMovementCutOffContext()
1616 SvXMLImportContext *ScXMLMovementCutOffContext::CreateChildContext( sal_uInt16 nPrefix,
1617 const OUString& rLocalName,
1618 const ::com::sun::star::uno::Reference<
1619 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1621 return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1624 void ScXMLMovementCutOffContext::EndElement()
1628 ScXMLCutOffsContext::ScXMLCutOffsContext( ScXMLImport& rImport,
1629 sal_uInt16 nPrfx,
1630 const OUString& rLName,
1631 const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */,
1632 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1633 SvXMLImportContext( rImport, nPrfx, rLName ),
1634 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1636 // here are no attributes
1639 ScXMLCutOffsContext::~ScXMLCutOffsContext()
1643 SvXMLImportContext *ScXMLCutOffsContext::CreateChildContext( sal_uInt16 nPrefix,
1644 const OUString& rLocalName,
1645 const ::com::sun::star::uno::Reference<
1646 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1648 SvXMLImportContext *pContext(0);
1650 if (nPrefix == XML_NAMESPACE_TABLE)
1652 if (IsXMLToken(rLocalName, XML_INSERTION_CUT_OFF))
1653 pContext = new ScXMLInsertionCutOffContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1654 else if (IsXMLToken(rLocalName, XML_MOVEMENT_CUT_OFF))
1655 pContext = new ScXMLMovementCutOffContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1658 if( !pContext )
1659 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1661 return pContext;
1664 void ScXMLCutOffsContext::EndElement()
1668 ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport& rImport,
1669 sal_uInt16 nPrfx,
1670 const OUString& rLName,
1671 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1672 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1673 SvXMLImportContext( rImport, nPrfx, rLName ),
1674 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1676 sal_uInt32 nActionNumber(0);
1677 sal_uInt32 nRejectingNumber(0);
1678 sal_Int32 nPosition(0);
1679 sal_Int32 nMultiSpanned(0);
1680 sal_Int32 nTable(0);
1681 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1682 ScChangeActionType nActionType(SC_CAT_DELETE_COLS);
1684 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1685 for( sal_Int16 i=0; i < nAttrCount; i++ )
1687 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1688 OUString aLocalName;
1689 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1690 sAttrName, &aLocalName ));
1691 const OUString& sValue(xAttrList->getValueByIndex( i ));
1693 if (nPrefix == XML_NAMESPACE_TABLE)
1695 if (IsXMLToken(aLocalName, XML_ID))
1697 nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1699 else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1701 if (IsXMLToken(sValue, XML_ACCEPTED))
1702 nActionState = SC_CAS_ACCEPTED;
1703 else if (IsXMLToken(sValue, XML_REJECTED))
1704 nActionState = SC_CAS_REJECTED;
1706 else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1708 nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1710 else if (IsXMLToken(aLocalName, XML_TYPE))
1712 if (IsXMLToken(sValue, XML_ROW))
1714 nActionType = SC_CAT_DELETE_ROWS;
1716 else if (IsXMLToken(aLocalName, XML_TABLE))
1718 nActionType = SC_CAT_DELETE_TABS;
1721 else if (IsXMLToken(aLocalName, XML_POSITION))
1723 ::sax::Converter::convertNumber(nPosition, sValue);
1725 else if (IsXMLToken(aLocalName, XML_TABLE))
1727 ::sax::Converter::convertNumber(nTable, sValue);
1729 else if (IsXMLToken(aLocalName, XML_MULTI_DELETION_SPANNED))
1731 ::sax::Converter::convertNumber(nMultiSpanned, sValue);
1736 pChangeTrackingImportHelper->StartChangeAction(nActionType);
1737 pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1738 pChangeTrackingImportHelper->SetActionState(nActionState);
1739 pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1740 pChangeTrackingImportHelper->SetPosition(nPosition, 1, nTable);
1741 pChangeTrackingImportHelper->SetMultiSpanned(static_cast<sal_Int16>(nMultiSpanned));
1744 ScXMLDeletionContext::~ScXMLDeletionContext()
1748 SvXMLImportContext *ScXMLDeletionContext::CreateChildContext( sal_uInt16 nPrefix,
1749 const OUString& rLocalName,
1750 const ::com::sun::star::uno::Reference<
1751 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1753 SvXMLImportContext *pContext(0);
1755 if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1757 pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1759 else if (nPrefix == XML_NAMESPACE_TABLE)
1761 if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1762 pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1763 else if (IsXMLToken(rLocalName, XML_DELETIONS))
1764 pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1765 else if (IsXMLToken(rLocalName, XML_CUT_OFFS) || rLocalName == "cut_offs")
1766 pContext = new ScXMLCutOffsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1767 else
1769 OSL_FAIL("don't know this");
1773 if( !pContext )
1774 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1776 return pContext;
1779 void ScXMLDeletionContext::EndElement()
1781 pChangeTrackingImportHelper->EndChangeAction();
1784 ScXMLMovementContext::ScXMLMovementContext( ScXMLImport& rImport,
1785 sal_uInt16 nPrfx,
1786 const OUString& rLName,
1787 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1788 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1789 SvXMLImportContext( rImport, nPrfx, rLName ),
1790 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1792 sal_uInt32 nActionNumber(0);
1793 sal_uInt32 nRejectingNumber(0);
1794 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1796 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1797 for( sal_Int16 i=0; i < nAttrCount; ++i )
1799 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1800 OUString aLocalName;
1801 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1802 sAttrName, &aLocalName ));
1803 const OUString& sValue(xAttrList->getValueByIndex( i ));
1805 if (nPrefix == XML_NAMESPACE_TABLE)
1807 if (IsXMLToken(aLocalName, XML_ID))
1809 nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1811 else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1813 if (IsXMLToken(sValue, XML_ACCEPTED))
1814 nActionState = SC_CAS_ACCEPTED;
1815 else if (IsXMLToken(sValue, XML_REJECTED))
1816 nActionState = SC_CAS_REJECTED;
1818 else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1820 nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1825 pChangeTrackingImportHelper->StartChangeAction(SC_CAT_MOVE);
1826 pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1827 pChangeTrackingImportHelper->SetActionState(nActionState);
1828 pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1831 ScXMLMovementContext::~ScXMLMovementContext()
1835 SvXMLImportContext *ScXMLMovementContext::CreateChildContext( sal_uInt16 nPrefix,
1836 const OUString& rLocalName,
1837 const ::com::sun::star::uno::Reference<
1838 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1840 SvXMLImportContext *pContext(0);
1842 if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1844 pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1846 else if (nPrefix == XML_NAMESPACE_TABLE)
1848 if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1849 pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1850 else if (IsXMLToken(rLocalName, XML_DELETIONS))
1851 pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1852 else if (IsXMLToken(rLocalName, XML_SOURCE_RANGE_ADDRESS))
1853 pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aSourceRange);
1854 else if (IsXMLToken(rLocalName, XML_TARGET_RANGE_ADDRESS))
1855 pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aTargetRange);
1858 if( !pContext )
1859 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1861 return pContext;
1864 void ScXMLMovementContext::EndElement()
1866 pChangeTrackingImportHelper->SetMoveRanges(aSourceRange, aTargetRange);
1867 pChangeTrackingImportHelper->EndChangeAction();
1870 ScXMLRejectionContext::ScXMLRejectionContext( ScXMLImport& rImport,
1871 sal_uInt16 nPrfx,
1872 const OUString& rLName,
1873 const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1874 ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1875 SvXMLImportContext( rImport, nPrfx, rLName ),
1876 pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1878 sal_uInt32 nActionNumber(0);
1879 sal_uInt32 nRejectingNumber(0);
1880 ScChangeActionState nActionState(SC_CAS_VIRGIN);
1882 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1883 for( sal_Int16 i=0; i < nAttrCount; ++i )
1885 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
1886 OUString aLocalName;
1887 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1888 sAttrName, &aLocalName ));
1889 const OUString& sValue(xAttrList->getValueByIndex( i ));
1891 if (nPrefix == XML_NAMESPACE_TABLE)
1893 if (IsXMLToken(aLocalName, XML_ID))
1895 nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1897 else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1899 if (IsXMLToken(sValue, XML_ACCEPTED))
1900 nActionState = SC_CAS_ACCEPTED;
1901 else if (IsXMLToken(sValue, XML_REJECTED))
1902 nActionState = SC_CAS_REJECTED;
1904 else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1906 nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1911 pChangeTrackingImportHelper->StartChangeAction(SC_CAT_MOVE);
1912 pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1913 pChangeTrackingImportHelper->SetActionState(nActionState);
1914 pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1917 ScXMLRejectionContext::~ScXMLRejectionContext()
1921 SvXMLImportContext *ScXMLRejectionContext::CreateChildContext( sal_uInt16 nPrefix,
1922 const OUString& rLocalName,
1923 const ::com::sun::star::uno::Reference<
1924 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1926 SvXMLImportContext *pContext(0);
1928 if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1930 pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1932 else if (nPrefix == XML_NAMESPACE_TABLE)
1934 if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1935 pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1936 else if (IsXMLToken(rLocalName, XML_DELETIONS))
1937 pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1940 if( !pContext )
1941 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1943 return pContext;
1946 void ScXMLRejectionContext::EndElement()
1948 pChangeTrackingImportHelper->EndChangeAction();
1951 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */